package com.newtouch.bxzs.business.train.controller;

import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.newtouch.bxzs.business.config.MyLog;
import com.newtouch.bxzs.business.train.model.bo.ExaminationQuestionSetQuestionBankListBO;
import com.newtouch.bxzs.business.train.model.bo.QuestionBankListBO;
import com.newtouch.bxzs.business.train.model.vo.ExaminationQuestionSetQuestionBankListVO;
import com.newtouch.bxzs.business.train.model.vo.ModifyQuestionBankInfoVO;
import com.newtouch.bxzs.business.train.model.vo.QuestionBankListVO;
import com.newtouch.bxzs.business.train.service.QuestionBankService;
import com.newtouch.bxzs.common.base.response.BaseResponse;
import com.newtouch.bxzs.common.base.response.RespGenerator;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;

/**
 * 题库管理
 * 
 * <p>
 * <b>History:</b>
 * <table border="1">
 * <tr>
 * <th>Date</th>
 * <th>Operator</th>
 * <th>Memo</th>
 * </tr>
 * <tr>
 * <td>2021/1/21</td>
 * <td>lanwei</td>
 * <td>Create</td>
 * </tr>
 * </table>
 *
 * @author lanwei
 * @version 1.0.0
 * @since 1.0.0
 */
@Api(tags = "题库管理")
@RestController
@RequestMapping("/questionsBankController")
@SuppressWarnings("unchecked")
public class QuestionBankController {

	/**
	 * 静态变量：系统日志
	 */
	private static final Log logger = LogFactory.getLog(QuestionBankController.class);

	@Autowired
	private QuestionBankService questionBankService;

	/**
	 * 查询题库列表
	 * 
	 * @param questionBankListVO
	 * @return
	 */
	@ApiOperation(value = "查询题库列表")
	@PostMapping("/getQuestionBanks")
	@MyLog(systemFunctionName = "题库管理", systemFunctionUrl = "/questionsBankController/getQuestionBanks", userOperationType = 4, userOperationSummary = "查询题库列表")
	public BaseResponse<QuestionBankListBO> getQuestionBanks(
			@RequestBody @ApiParam(name = "questionBankListVO", value = "查看题库列表VO类", required = true) QuestionBankListVO questionBankListVO) {
		logger.info("查询题库列表");
		return RespGenerator.returnOK(questionBankService.getQuestionBankList(questionBankListVO));
	}

	/**
	 * 创建、修改题库信息
	 * 
	 * @param modifyQuestionBankInfoVO
	 */
	@ApiOperation(value = "创建、修改题库信息")
	@PostMapping("/modifyQuestionBankInfo")
	@MyLog(systemFunctionName = "题库管理", systemFunctionUrl = "/questionsBankController/modifyQuestionBankInfo", userOperationType = 5, userOperationSummary = "创建、修改题库信息")
	public BaseResponse<String> modifyQuestionBankInfo(
			@RequestBody @ApiParam(name = "modifyQuestionBankInfoVO", value = "创建、修改题库VO类", required = true) ModifyQuestionBankInfoVO modifyQuestionBankInfoVO) {
		logger.info("创建、修改题库");
		return RespGenerator.returnOK(questionBankService.modifyQuestionBankInfo(modifyQuestionBankInfoVO));
	}

	/**
	 * 删除题库
	 * 
	 * @param questionBankIds
	 * @returnR
	 */
	@ApiOperation(value = "删除题库")
	@PostMapping("/deleteQuestionBank")
	@MyLog(systemFunctionName = "题库管理", systemFunctionUrl = "/questionsBankController/deleteQuestionBank", userOperationType = 3, userOperationSummary = "删除题库")
	public BaseResponse<Integer> deleteQuestionBank(
			@RequestBody @ApiParam(name = "questionBankIds", value = "题库id集合", required = true) List<String> questionBankIds) {
		logger.info("删除题库");
		return RespGenerator.returnOK(questionBankService.deleteQuestionBank(questionBankIds));
	}
	
	/**
     * 试题设置题库列表
     * @param examinationQuestionId
     * @return
     */
    @ApiOperation(value = "试题设置题库列表")
    @PostMapping("/getExaminationQuestionSetQuestionBankList")
    @MyLog(systemFunctionName = "题库管理", systemFunctionUrl = "/questionsBankController/getQuestionBanks", userOperationType = 4, userOperationSummary = "查询题库列表")
    public BaseResponse<ExaminationQuestionSetQuestionBankListBO> getQuestionBanks(@RequestBody @ApiParam(name = "examinationQuestionSetQuestionBankListVO", value = "试题设置归属题库列表VO", required = true) ExaminationQuestionSetQuestionBankListVO examinationQuestionSetQuestionBankListVO) {
        logger.info("查询试题设置题库列表");
        return RespGenerator.returnOK(questionBankService.getExaminationQuestionSetQuestionBankList(examinationQuestionSetQuestionBankListVO));
    }
}
